//
//  BrowserViewController.m
//  MoneyLog
//
//  Created by Max on 11-4-10.
//  Copyright 2011年 wicresoft. All rights reserved.
//

#import "BrowserViewController.h"
#import "GlobalDef.h"

@implementation BrowserViewController

@synthesize _tableView;
@synthesize _webView;
@synthesize webViewNormal,webViewMaximum;
@synthesize viewMask;
@synthesize titleLable;
//@synthesize urlText;
@synthesize urlTextNormal,urlTextEditing,urlTextMinimum;
//@synthesize searchText;
@synthesize searchTextNormal,searchTextEditing,searchTextMinimum;
//@synthesize cancelButton;
@synthesize cancelButtonFrame;

@synthesize buffer;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)dealloc
{
    [_tableView release];
    [toolbar release];
    _webView.delegate = nil;
	[_webView release];
	[viewMask release];
	[titleLable release];
	[urlText release];
	[searchText release];
	[cancelButton release];
    
    [buffer release];
    [super dealloc];
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
	[self.navigationController setNavigationBarHidden:YES animated:YES];
	//[[UIApplication sharedApplication] setStatusBarOrientation:UIDeviceOrientationPortrait];
	
    buffer=[[NSMutableData alloc] initWithLength: 0];
    
	CGRect appRect = [[UIScreen mainScreen] applicationFrame];
    toolbar=[[UIToolbar alloc] initWithFrame:CGRectMake(0,-2,appRect.size.width, 50)];
	//[toolbar sizeToFit];
    toolbar.barStyle=UIBarStyleDefault;
	//toolbar.autoresizingMask = UIViewAutoresizingFlexibleHeight;
    //[self.view addSubview:toolbar];
	
	//Title 
	titleLable=[[UILabel alloc] initWithFrame:CGRectMake(0, 1, appRect.size.width, 18)];
	titleLable.font=[UIFont fontWithName:@"Arial" size:10];
	titleLable.backgroundColor=[UIColor clearColor];
	titleLable.textAlignment=UITextAlignmentCenter;
	titleLable.text=@"无标题";
	titleLable.adjustsFontSizeToFitWidth=YES;
	titleLable.autoresizingMask= UIViewAutoresizingFlexibleWidth;
	[toolbar addSubview:titleLable];
 	
	//url textfield
	urlText=[[UITextField alloc] initWithFrame:CGRectMake(16, 18, 200, 26)];
	urlText.borderStyle=UITextBorderStyleRoundedRect;
	urlText.textColor=[UIColor blackColor];
	urlText.autoresizingMask = UIViewAutoresizingFlexibleWidth;
	//text.autocorrectionType = UITextAutocorrectionTypeNo;
	urlText.keyboardType=UIKeyboardTypeURL;
	//text.autocapitalizationType=UITextAutocapitalizationTypeNone;
    urlText.delegate = self;
	urlText.placeholder=@"enter a url";
    urlText.tag=0xFF01;
	urlText.adjustsFontSizeToFitWidth=YES;
    urlText.returnKeyType=UIReturnKeyGo;
	[toolbar addSubview:urlText];
	
	//url.text=@"http://www.wicresoft.jp:443/svn/hj_sscom";
    urlText.text=@"http://www.baidu.com";
	//[urlText release];
	
	//search textfield
    searchText = [[UITextField alloc] initWithFrame:CGRectMake(214, 18, 100, 26)];
	searchText.borderStyle=UITextBorderStyleRoundedRect;
    searchText.delegate=self;
    searchText.tag=0xFF02;
	searchText.adjustsFontSizeToFitWidth=YES;
    searchText.returnKeyType=UIReturnKeySearch;
	[toolbar addSubview:searchText];
	
	//cancel button
    cancelButton=[[UIButton alloc] initWithFrame:CGRectMake(260, 18, 40, 26)];
	//cancelButton.buttonType=UIButtonTypeRoundedRect;
	cancelButton.titleLabel.text=@"取消";
	//cancelButton.hidden=YES;
	[cancelButton addTarget:self action:@selector(cancelAction:) forControlEvents:UIControlEventTouchUpInside];
	[toolbar addSubview:cancelButton]; 
	
	//web view
    _webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, appRect.size.width, appRect.size.height-44)];
	_webView.backgroundColor = [UIColor whiteColor];
	_webView.scalesPageToFit = YES;
	_webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
	_webView.delegate = self;
	//[self.view addSubview:_webView];
	
	//Tool bar
	UIToolbar *toolbarBottom=[[UIToolbar alloc] initWithFrame:CGRectMake(0,appRect.size.height-44, appRect.size.width, 44)];
	toolbarBottom.barStyle=UIBarStyleDefault;
	toolbarBottom.autoresizingMask=UIViewAutoresizingFlexibleWidth;
	[self.view addSubview:toolbarBottom];
	[toolbarBottom release];
	
	viewMask = [[UIView alloc] initWithFrame:CGRectMake(0,50-2, appRect.size.width, appRect.size.height-50-44)];
	viewMask.alpha=0.68;
	viewMask.backgroundColor = [UIColor blackColor];
	viewMask.hidden = YES;
	//[self.view addSubview:viewMask];
    
    //self._tableView.rowHeight = appRect.size.height -50-40;
    [self._tableView setTableHeaderView:toolbar];
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations (8, 12, 200, 28)]; (210, 12, 100, 28)];
	if (!isPad) {
		if (UIInterfaceOrientationPortrait == interfaceOrientation 
			|| UIInterfaceOrientationPortraitUpsideDown == interfaceOrientation) {
			urlTextNormal = CGRectMake(8, 18, 200, 26);
			urlTextEditing = urlTextNormal;
			urlTextEditing.size.width = 240;
			urlTextMinimum = urlTextNormal;
			urlTextMinimum.size.width = 0;
			
			searchTextNormal = CGRectMake(210, 18, 100, 26);
			searchTextEditing = urlTextEditing;
			searchTextEditing.size.width -= 10;
			searchTextMinimum = searchTextNormal;
			searchTextMinimum.size.width = 0;
			
			cancelButtonFrame =CGRectMake(240, 18, 60, 26); 			
		} else if (UIInterfaceOrientationLandscapeLeft == interfaceOrientation
				   || UIInterfaceOrientationLandscapeRight == interfaceOrientation) {
			urlTextNormal = CGRectMake(8, 14, 320, 28);
			urlTextEditing = urlTextNormal;
			urlTextEditing.size.width = 400;
			urlTextMinimum = urlTextNormal;
			urlTextMinimum.size.width = 0;
			
			searchTextNormal = CGRectMake(330, 18, 140, 26);
			searchTextEditing = urlTextEditing;
			searchTextEditing.size.width -= 10;
			searchTextMinimum = searchTextNormal;
			searchTextMinimum.size.width = 0;
		}
		
		[UIView beginAnimations:nil context:nil];
		if ([urlText isEditing]) {
			urlText.frame = urlTextEditing;
			searchText.frame = searchTextMinimum;
		} else if ([searchText isEditing]) {
			urlText.frame = urlTextMinimum;
			searchText.frame = searchTextEditing;
		}
		
		if (![urlText isEditing] && ![searchText isEditing]) {
			urlText.frame = urlTextNormal;
			searchText.frame = searchTextNormal;
		}
		[UIView commitAnimations];
	}
	
	return YES;	
}

#pragma mark - * UIViewController delegate methods

- (void)viewWillAppear:(BOOL)animated
{
	self._webView.delegate = self;	// setup the delegate as the web view is shown
    self._tableView.tableHeaderView = nil;
}

- (void)viewWillDisappear:(BOOL)animated
{
    [_webView stopLoading];	// in case the web view is still loading its content
	self._webView.delegate = nil;	// disconnect the delegate as the webview is hidden
	[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}

#pragma mark - * Table view data source

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    CGRect appRect = [[UIScreen mainScreen] applicationFrame];
    return appRect.size.height -44;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    //#warning Potentially incomplete method implementation.
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    //#warning Incomplete method implementation.
    // Return the number of rows in the section.
    return 1;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    }
    
    //web view
//    CGRect appRect = [[UIScreen mainScreen] applicationFrame];
//    if (_webView!=nil) {
//        [_webView release];
//    }
//    _webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 50-2, appRect.size.width, appRect.size.height-50-44)];
//	_webView.backgroundColor = [UIColor whiteColor];
//	_webView.scalesPageToFit = YES;
//	_webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
//	_webView.delegate = self;

    [cell.contentView addSubview:self._webView];
    cell.accessoryType = UITableViewCellAccessoryNone;
    
    return cell;
}

// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the specified item to be editable.
    return YES;
}

- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return UITableViewCellEditingStyleNone;
}

// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
    
}

- (void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
	NSLog(@"section: %d, row: %d", indexPath.section, indexPath.row);
}

- (void)tableView:(UITableView *)tableView didEndEditingRowAtIndexPath:(NSIndexPath *)indexPath
{
	NSLog(@"section: %d, row: %d", indexPath.section, indexPath.row);
}

/*
 // Override to support rearranging the table view.
 - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
 {
 }
 */

/*
 // Override to support conditional rearranging of the table view.
 - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
 {
 // Return NO if you do not want the item to be re-orderable.
 return YES;
 }
 */

#pragma mark - * Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
        
}

#pragma mark - * UIScrollViewDelegate Methods

- (void)scrollViewDidScroll:(UIScrollView *)scrollView{	
    
}

- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    self._tableView.tableHeaderView = toolbar;
}

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate{
}


#pragma mark - * UITextField delegate methods

// this helps dismiss the keyboard when the "Done" button is clicked
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
	[textField resignFirstResponder];
    
    if (textField.tag==0xFF01) {
        url = [NSURL URLWithString:[textField text]];
        NSURLRequest *request=[NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0 ];
    
        if ( [NSURLConnection canHandleRequest:request]) {
           
            NSURLConnection *connection=[[NSURLConnection alloc] initWithRequest:request delegate:self];
        
            if (connection) {
                [self._webView loadRequest:request];
            }
            else {
                NSLog(@"connection failed.");
            }
            [connection release];
        }
        else {
            NSLog(@"Could not resolve the address.");  
        } 
    }
	return YES;
}

// became first responder
- (void)textFieldDidBeginEditing:(UITextField *)textField{
   
	viewMask.hidden = NO;
    if (textField.tag == 0xFF01) {
        [UIView beginAnimations:nil context:nil];
        urlText.frame=urlTextEditing;
        searchText.frame=searchTextMinimum;
		cancelButton.hidden = NO;
        [UIView commitAnimations];
    }
    else
    {
		[UIView beginAnimations:nil context:nil];
		searchText.frame = searchTextEditing;
		urlText.frame = urlTextMinimum;
		cancelButton.hidden = NO;
		[UIView commitAnimations];
    }
}

//to disallow the editing session to end
- (void)textFieldDidEndEditing:(UITextField *)textField{

	viewMask.hidden = YES;
	[UIView beginAnimations:nil context:nil];
	urlText.frame=urlTextNormal;
	searchText.frame=searchTextNormal;
	cancelButton.hidden = YES;
	[UIView commitAnimations];
	
	if (textField.tag == 0xFF01) {
		 
	}
	else {
		
	}

}

#pragma mark - * NSURLConnection delegate

- (NSURLRequest *)connection:(NSURLConnection *)connection willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response {
	 
	NSLog(@"url=%@",request.URL.absoluteString);
    
    NSLog(@"absoluteString=%@",response.URL.absoluteString);
    NSLog(@"MIMEType=%@",[response MIMEType]);
    NSLog(@"textEncodingName=%@",[response textEncodingName]);
    NSLog(@"suggestedFilename=%@",[response suggestedFilename]);
	return request;
}

- (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
    NSLog(@"Error times:%d",[challenge previousFailureCount]);
    
	NSURLProtectionSpace *space = [challenge protectionSpace];
	if (NSURLAuthenticationMethodServerTrust != [space authenticationMethod]) {
		[_webView stopLoading];
		// TODO: UI(Authentication Dlg)
		do {
			//m_nAuthenticationDialogResult = -1;
			UIAlertView *alerView = [[UIAlertView alloc]
								   initWithTitle:@"权限认证"
								   message:NSLocalizedString(@"\n\n\n", nil)
								   delegate:self
								   cancelButtonTitle:@"取消"
								   otherButtonTitles:@"确定",
								   nil];
			UITextField *nameText = [[UITextField alloc] initWithFrame:CGRectMake( 10, 40, 260, 26 )];
			[nameText setBackgroundColor:[UIColor whiteColor]];
			nameText.borderStyle = UITextBorderStyleNone;
			nameText.backgroundColor = [UIColor whiteColor];
			nameText.placeholder = @"帐号";
			[alerView addSubview:nameText];
			[nameText release];
            
            UILabel *lineLable=[[UILabel alloc] initWithFrame:CGRectMake(10, 66, 260, 4)];
            lineLable.lineBreakMode = UILineBreakModeWordWrap;
            lineLable.numberOfLines = 0;
            lineLable.textColor = [UIColor grayColor];
            lineLable.text = @"----------------------------------------------------";
            [alerView addSubview:lineLable];
            [lineLable release];
			
			UITextField *passwordText = [[UITextField alloc] initWithFrame:CGRectMake( 10, 70, 260, 26 )];
			[passwordText setSecureTextEntry:YES];
			[passwordText setBackgroundColor:[UIColor whiteColor]];
			passwordText.borderStyle = UITextBorderStyleNone;
			passwordText.backgroundColor = [UIColor whiteColor];
			passwordText.placeholder = @"密码";
			[alerView addSubview:passwordText];
			[passwordText release];
			
			
			[alerView setTransform:CGAffineTransformMakeTranslation(0, -60)];
			[alerView show];
			[alerView release];
			
			NSDate *loopDate;
			loopDate = [NSDate dateWithTimeIntervalSinceNow:0.1];
			BOOL output = NO;
			while ((dialogResult == -1) && ([[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:loopDate])) {
				loopDate = [NSDate dateWithTimeIntervalSinceNow:0.1];
				if (!output) {
					NSLog(@"--> in while");
					output = YES;
				}
			} 	
			
		}while (-1 == dialogResult );
		/*
		if (1 == dialogResult) {
			NSString *userName=[m_userField.text length]==0 ? @"":m_userField.text;
			NSString *password = [m_passwordField.text length]==0 ? @"":m_passwordField.text;
			
			if ([userName length]!=0 || [password length] !=0 ) {
				NSURLCredential *newCredential;
				newCredential = [NSURLCredential 
								 credentialWithUser:userName
								 password:password 
								 persistence:NSURLCredentialPersistenceForSession];
				
				[[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge];
                [m_aivLoading startAnimating];
                NSURL *url=[NSURL URLWithString:m_tfUrl.text];
                NSURLRequest *request = [NSURLRequest requestWithURL:url];// cachePolicy:NSURLRequestReturnCacheDataDontLoad timeoutInterval:60.0];
                [m_wvWebView loadRequest:request];
			}
			else {
				[[challenge sender] continueWithoutCredentialForAuthenticationChallenge:challenge];
                [m_wvWebView reload];
			}
		}
        else if (0 == m_nAuthenticationDialogResult) {
			// user cancel.
			[[challenge sender] cancelAuthenticationChallenge:challenge];
		}
        else {
			assert(NO);
		}
		 */
		return;
	}
}

// 你可以在里面判断返回结果, 或者处理返回的http头中的信息
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
	//NSHTTPURLResponse *httpResponse=(NSHTTPURLResponse*)response;
    
    //[connection cancel];
	//[connection release];
}

// 每收到一次数据, 会调用一次
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    [buffer appendData:data];
}

// 网络错误时触发
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
    /*
	NSString * dataStr=[[NSString alloc] initWithData:self.buffer encoding:NSASCIIStringEncoding];
	UIAlertView * alertView =[[UIAlertView alloc]
							  initWithTitle:@"失败" 
							  message:dataStr
							  delegate:nil 
							  cancelButtonTitle:@"OK"
							  otherButtonTitles:nil];
	alertView.tag=0xFFFF;
	[alertView show];
	[alertView release];
     */
	
}

// 全部数据接收完毕时触发
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
	
    /*
	NSString * dataStr=[[NSString alloc] initWithData:self.buffer encoding:NSASCIIStringEncoding];
	UIAlertView * alertView =[[UIAlertView alloc]
							  initWithTitle:@"成功" 
							  message:dataStr
							  delegate:nil 
							  cancelButtonTitle:@"OK"
							  otherButtonTitles:nil];
	alertView.tag=0xFFFF;
	[alertView show];
	[alertView release];
     */
//    NSLog(@"url = %@",url);
//    
//    NSString *dataString =[[NSString alloc] initWithData:buffer encoding:NSASCIIStringEncoding];
//    [_webView loadHTMLString:dataString baseURL:url];
//    [dataString release];
}

#pragma mark - * UIWebViewDelegate

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
    
    switch (navigationType) {   
		case UIWebViewNavigationTypeLinkClicked:
			NSLog(@"%@", @"Link Clicked");
			break;
		case UIWebViewNavigationTypeFormSubmitted:
			NSLog(@"%@", @"Form Submitted");
			break;
		case UIWebViewNavigationTypeBackForward:
			NSLog(@"%@", @"Back Forward");
			break;
		case UIWebViewNavigationTypeReload:
			NSLog(@"%@", @"Reload");
			break;
		case UIWebViewNavigationTypeFormResubmitted:
			NSLog(@"%@", @"Form Resubmitted");
			break;
		case UIWebViewNavigationTypeOther:
			NSLog(@"%@", @"Other");
			break;
		default:
			NSLog(@"%@", @"unknown");
			break;
	}

    
    NSLog(@"request url = %@",[[request URL] absoluteString]);
    
//    NSString *urlString = [[request URL] absoluteString];
//    NSRange range = [urlString rangeOfString:[url absoluteString]];
//    if (range.length != 0) {
//        return YES;
//    }
//    
//    NSURLConnection *connection=[[NSURLConnection alloc] initWithRequest:request delegate:self];
//    
//    if (connection) {
//        //[self._webView loadRequest:request];
//    }
//    else {
//        NSLog(@"connection failed.");
//    }
//    [connection release];

    return YES;
}

- (void)webViewDidStartLoad:(UIWebView *)webView
{
	// starting the load, show the activity indicator in the status bar
	[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
	// finished loading, hide the activity indicator in the status bar
	titleLable.text=[webView stringByEvaluatingJavaScriptFromString:@"document.title"];
	NSLog(@"back=%d",webView.canGoBack);
	//NSLog(@"back=%d",webView.canGoBack);
	[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
	// load error, hide the activity indicator in the status bar
	[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
    
	// report the error inside the webview
	NSString* errorString = [NSString stringWithFormat:
							 @"<html><center><font size=+5 color='red'>An error occurred:<br>%@</font></center></html>",
							 error.localizedDescription];
	[webView loadHTMLString:errorString baseURL:nil];
}


#pragma mark * UIAlertView Delegate

- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{
	__OUTPUT_CURRENT_METHOD_NAME__
	NSLog(@"--> Button Index: %d", buttonIndex);
	dialogResult = buttonIndex;
	if (0 == buttonIndex) {	
		//m_nAuthenticationDialogResult = 0;
		NSLog(@"--> Continue");
	} else if (1 == buttonIndex) {
		//m_nAuthenticationDialogResult = 1;
		NSLog(@"--> Cancel");
	} else if (2 == buttonIndex) {
		//m_nAuthenticationDialogResult = 2;
		NSLog(@"--> Details");
	}
}


#pragma mark Actions

- (void)cancelAction:(id)sender{
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Authentication Failure" 
													message:@"Website did not accept the username and password."
												   delegate:nil
										  cancelButtonTitle:@"OK" 
										  otherButtonTitles:nil];
	[alert show];
	[alert release];
}


@end
